package com.ruoyi.web.controller.admin;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IBdmFileImportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * 导入Controller
 */
@RestController
@RequestMapping("/bdmFile")
public class BdmFileImportController extends BaseController {

    @Autowired
    private IBdmFileImportService bdmFileImportService;


    /**
     * 批量导入用户数据
     *
     * @param file
     * @return
     */
    @Log(title = "批量导入用户数据", businessType = BusinessType.IMPORT)
    @PostMapping("/importUserInfo")
    public AjaxResult importUserInfo(MultipartFile file) throws IOException {
        bdmFileImportService.importUserInfo2(file);
        return success();
    }

    /**
     * 批量导入库存数据
     *
     * @param file
     * @return
     */
    @Log(title = "批量导入库存数据", businessType = BusinessType.IMPORT)
    @PostMapping("/importInventoryInfo")
    public AjaxResult importInventoryInfo(MultipartFile file) {
        bdmFileImportService.importInventoryInfo(file);
        return success();
    }

}
